<template>
<!-- 写手端 菜单栏 -->
  <div class="headPortrait">
      <div class="cover">
        <span @click="state.visiableSelectArr=!state.visiableSelectArr">{{state.userInfo.nickname}}</span>
        <img @click="state.visiableSelectArr=!state.visiableSelectArr" :src="state.userInfo.avatar" alt="">
        <div v-if="state.visiableSelectArr" class="selectArr">
            <div class="item" @click="router.push('/login')">登出</div>
        </div>
      </div>
  </div>
</template>
<script>
import { getCurrentInstance, onMounted, reactive } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
const state = reactive({
    userInfo:{},
    visiableSelectArr:false,

  });
export default {
  name: 'headPortrait',
  components: {},
  setup(props,{emit}) {
      const ctx = getCurrentInstance();
      const _this = ctx.appContext.config.globalProperties
      const router = useRouter();
      const store = useStore();
      function getUserInfo(){
        _this.$request({
          url:'/api/pcLogin/get_admininfo'
        }).then(res=>{
          // console.log(res);
          if (res.code==1) {
            state.userInfo = res.data 
          }
        })
      };
      onMounted(()=>{
          getUserInfo()
      });
      return{
        state,getUserInfo,router
      }
  },
  props: {},
  watch: {},
  methods: {},
  computed: {},
  mounted () {
  }
}
</script>
<style lang="scss" scoped>
.headPortrait{
  width: 100%;
  height: 40vh;
  overflow: hidden;
  background: #4977fc;
  .cover{
      height: 90px;
      display: flex;
      justify-content: flex-end;
      align-items: center;
      position: relative;
      .selectArr{
        position: absolute;
        top: 92%;
        right: 4%;
        width: 100px;
        transition: all 1s;
        background-color: #fff;
        z-index: 99;
        box-shadow: 1px 1px 3px rgba(0,0,0,.1),0px 1px 3px rgba(0,0,0,.1) inset;
        border-radius: 4px;
         &::before{
           content: '';
            position: absolute;
            top: -15%;
            right: 15%;
            width: 0;
            height: 0;
            border-bottom: 10px solid #fff;
            border-left: 5px solid transparent;
            border-right: 5px solid transparent;
          }
        .item{
          height: 50px;
          display: grid;
          color: #4977fc;
          place-items: center;
          cursor: pointer;
        }
      }
      // background-color: pink;
      img{
        width: 60px;
        height: 60px;
        border-radius: 50%;
        margin-left: 16px;
        margin-right: 40px;
        cursor: pointer;
      }
      span{
        color: #fff;
        cursor: pointer;
      }
  }
  // background-color: pink;

}
</style>
